/**
 * cn.com.oceansoft.modules.profile.controller.ProfileController
 *
 * @author chenw
 * @create 16/4/27.21:39
 * @email javacspring@hotmail.com
 */

package cn.com.oceansoft.modules.profile.controller;

import cn.com.oceansoft.framework.kits.ApiResult;
import cn.com.oceansoft.modules.profile.service.IProfileService;
import nl.captcha.Captcha;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

/**
 * @author chenw
 * @create 16/4/27 21:39
 * @email javacspring@gmail.com
 */
@Controller
@RequestMapping("profile")
public class ProfileController {

    @Resource
    private IProfileService profileService;

    @ResponseBody
    @RequestMapping(value = "auth", method = POST)
    public ApiResult login(@RequestBody Map data) {
        return ApiResult.succ("查询成功!",
                this.profileService.findByLoginIdAndPwd(
                        data.get("loginId").toString(),
                        data.get("password").toString()));
    }

    @ResponseBody
    @RequestMapping(value = "{id}", method = GET)
    public ApiResult login(@PathVariable("id") String id) {
        return ApiResult.succ("查询成功!", this.profileService.findById(id));
    }


}
